package com.swotxu.firstribbonserver.web;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Date: 2020/7/9 20:43
 * @Author: swotXu
 */
@RestController
public class MyController {

    @RequestMapping(value = "/user/{userId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public UserInfo findUser(@PathVariable("userId") Integer userId, HttpServletRequest request){
        UserInfo userInfo = new UserInfo(userId, "swotxu", 18, request.getRequestURL().toString());
        return userInfo;
    }

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String findUser(){
        return "hello";
    }
}
